< previous page page_208 next page >

Page 208
7017a6ead0e3c4111b47a554df321e9f.gif
   ' Buffer is too small-Resize to selected size
   RasEntryCount = BufferSize / RasEntrySize
   ReDim RasEntryBuffer(RasEntryCount - 1)
   Res = RasEnumEntries(0, vbNullString, RasEntryBuffer(0), _
   BufferSize, RasEntries)
End If
I traced through the code. "Uh-oh," I said, "I'm getting an error 632 on the second call to RasEnumEntries. That doesn't make sense."
"Sure it does," laughed DT. "The dwSize parameter in the first entry in the array is initialized to the correct size, but the others are not."
"But the documentation doesn't say to initialize the dwSize fields in each entry in the structure, does it?"
"No, but it doesn't say not to, either. The documentation is vague on this."
"So how are we supposed to know to do this?"
"You guess. You try it both ways," DT grimaced. "Surely you're used to this kind of thing by now."
I quickly added some code to the function to initialize the dwSize field for each entry in the structure:
7017a6ead0e3c4111b47a554df321e9f.gif
Res = RasEnumEntries(0, vbNullString, RasEntryBuffer(0), BufferSize, _
      RasEntries)
If Res = 603 Then
   ' Buffer is too small-Resize to selected size
   RasEntryCount = BufferSize / RasEntrySize
   ReDim RasEntryBuffer(RasEntryCount - 1)
   For CurrentEntry = 0 To RasEntryCount - 1
      RasEntryBuffer(CurrentEntry).dwSize = RasEntrySize
   Next CurrentEntry
   Res = RasEnumEntries(0, vbNullString, RasEntryBuffer(0), _
         BufferSize, RasEntries)
End If
It worked! The result was 0, indicating that the function worked correctly. We were about to raise our juices to toast our success when DT glanced at the screen, stunned.
"It only works for the first entry in the phone book! The second entry is empty!"
TECH EDITOR'S NOTE The results described above may not work on your system. Read on to find out why.

 
< previous page page_208 next page >